/*
 * @Author: Leo.wang wanglizhigs@163.com
 * @Date: 2023-11-14 17:15:35
 * @LastEditors: Leo.wang wanglizhigs@163.com
 * @LastEditTime: 2023-11-17 09:24:10
 * @FilePath: /three-react/src/pages/Camera/Camera1.tsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { useEffect, useRef } from "react"
import createRender from '@/createRender';
import * as THREE from 'three'

const state = {}
export default function Page() {
  
  const container = useRef(null);
  useEffect(() => {
    if (!state.isMounted) {
      createRender(container)(render);
      state.isMounted = true;
    }
  }, [])



  function render(scene) {

    const box = new THREE.BoxGeometry(40,100, 20)
    const boxMaterial = new THREE.MeshLambertMaterial({
      color: 0xffff00
    })

    const mesh = new THREE.Mesh(box, boxMaterial);
    scene.add(mesh)

    const loader = new THREE.TextureLoader();
    const texture = loader.load('/public/12/光点.png')
   
    const material = new THREE.SpriteMaterial({
      color: 0x00ffff,
      map: texture
    })

    const sprite = new THREE.Sprite(material);
    sprite.scale.set(5, 5)

    sprite.position.set(0, 50, 0)
    sprite.translateY(5/2)
    scene.add(sprite)
  }

  return (
    <div id="container" className="full container" ref={container}></div>
  )
}